<?php

 /**
  * @package JooS
  * @subpackage PHPackager
  */

  require_once "JooS/Helper/Abstract.php";

  class JooS_PHPackager_Helper_Event extends JooS_Helper_Abstract {
    public function __invoke($name) {
      $args = func_get_args();
      array_shift($args);

      require_once "JooS/Loader.php";

      $event = null;
      if (JooS_Loader::loadClass($name)) {
        $rc = new ReflectionClass($name);
        if ($rc->isSubclassOf("JooS_Event")) {
          $event = $rc->getMethod("getInstance")->invoke(null);
        }
      }

      if (is_null($event)) {
        require_once "JooS/PHPackager/Helper/Exception.php";
      
        throw new JooS_PHPackager_Helper_Exception("Class for '$name' event not found");
      }
      return $event;
    }
  }
